package com.rich.util;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.util.Log;

public class FlashTsetUtils {

	private String flashLightON = "echo on > /sys/bus/platform/drivers/kd_camera_flashlight/flashContrl";
	private String flashLightOFF = "echo off > /sys/bus/platform/drivers/kd_camera_flashlight/flashContrl";
	private static Camera.Parameters parameters = null;
	private static Camera camera = null;

	public static void openFlash() {
		new Thread() {
			public void run() {
				try {
					Log.d("lrs", "openFlash");
					camera = Camera.open();
					camera.startPreview();
					parameters = camera.getParameters();
					parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
					camera.setParameters(parameters);
				} catch (Exception e) {

				}
			};
		}.start();
	}

	public static void closeFlash() {
		if (camera != null) {
			parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
			camera.setParameters(parameters);
			camera.stopPreview();
			camera.release();
			camera = null;
		}
	}
}
